package com.gwnet.cabinet.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gwnet.cabinet.domian.CabinetBoxLog;
import com.gwnet.cabinet.domian.bo.CabinetBoxLogPageBO;
import com.gwnet.cabinet.domian.bo.CabinetBoxLogViewBO;
import com.gwnet.cabinet.service.CabinetBoxLogService;
import com.gwnet.common.core.domain.ResponseResult;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 外卖柜-箱格表-日志表 前端控制器
 * </p>
 *
 * @author WangLiang
 * @since 2024-07-23
 */
@RestController
@RequestMapping("/cabinetBoxLog")
public class CabinetBoxLogController {

    private final CabinetBoxLogService logService;

    public CabinetBoxLogController(CabinetBoxLogService logService) {
        this.logService = logService;
    }

    /**
     * 分页获取开柜历史
     * @param pageBO
     * @return
     */
    @PostMapping("/page")
    public ResponseResult<IPage<CabinetBoxLog>> page(@RequestBody CabinetBoxLogPageBO pageBO){
        IPage<CabinetBoxLog> page = logService.page(pageBO);
        return ResponseResult.success(page);
    }

    /**
     * 根据日志ID获取日志详情
     * @param boxLogViewBO
     * @return
     */
    @PostMapping("/view")
    public ResponseResult<CabinetBoxLog> view(CabinetBoxLogViewBO boxLogViewBO){
        CabinetBoxLog view = logService.view(boxLogViewBO.getLogId());
        return ResponseResult.success(view);
    }


}

